package cc.example;

import reactor.core.publisher.Flux;

public class 创建序列generate {
    public static void main(String[] args) {
        // 同步线程下用
        Flux<Object> flux = Flux.generate(() -> 0, (state, synchronousSink) -> {
            if (state <= 10) {
                synchronousSink.next(state); // 传递数据；可能会抛出【不受检异常（运行时异常）、受检异常（编泽时异常）】
            } else {
                synchronousSink.complete();
            }

            return state + 1;
        });

        flux.log().subscribe();
    }
}
